"use strict";

let fs = require('fs');

let rs = fs.createWriteStream('./stream.txt', 'utf-8');

rs.on('data', (chunck) => {
  console.log('chunck: ' + chunck);
  console.log('----------');
})

rs.on('end', () => {
  console.log('end');
})

rs.on('error', (err) => {
  console.log('erro: ' + err);
})

rs.write('aabbcc');
rs.end();